package base.listener;

import java.util.ArrayList;
import java.util.List;

/**
 * \* User: Administrator
 * <p>
 * \* Date: 2020/11/10
 * <p>
 * \* Time: 15:42
 * <p>
 * \* Description:
 * \
 */
public class MyEventSource {
    private static List<MyListener> list = new ArrayList<>();

    public MyEventSource() {
    }

    public void addListener(MyListener listener) {
        list.add(listener);
    }

    public void removeListener(MyListener listener) {
        list.remove(listener);
    }

    public void publishEvent(MyEvent event) {
        for (MyListener listener : list) {
            listener.handleEvent(event);
        }
    }
}
